package com.cike.productmanager;

import com.cike.productmanager.util.DataApplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CListActivity extends Activity {

	private LinearLayout conivitylist;
	private TextView storenameview;
	private TextView photorequire;
	private TextView timelimitview;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.clist);
		
		conivitylist=(LinearLayout)findViewById(R.id.contractLinearLayout);
		
		for(int i=0;i<DataApplication.contractList.size();i++){
			
			View v = LayoutInflater.from(this).inflate(R.layout.contractitem,null);
			
            storenameview=(TextView)v.findViewById(R.id.storename);
            photorequire=(TextView)v.findViewById(R.id.photorequire);
            timelimitview=(TextView)v.findViewById(R.id.timetext);
            
            
            String storename = ((com.cike.productmanager.adt.Contract)DataApplication.contractList.get(i)).getStoreBelong();
            String timeLimit = ((com.cike.productmanager.adt.Contract)DataApplication.contractList.get(i)).getTimeLimit();
            
            
            storenameview.setText(storename);
            //TODO 是否需要拍照，未设计好
            photorequire.setText("需拍照");
            timelimitview.setText(timeLimit);
            
            final int num = i;
            
            v.setOnClickListener(new OnClickListener() {
				
            	/*在这里加入需要的门店信息传值，intent传值传一个排序，然后在ReadconContent向下再传到CheckContract
            	   中从ID获取数据库信息*/
				@Override
				public void onClick(View v) {
					Intent intent = new Intent (CListActivity.this,ReadConContent.class);			
					
					//传递排序过去
					intent.putExtra("ID", num);
					
					startActivity(intent);
				}
			});
            
            conivitylist.addView(v);
		}
		
		
	}
	
	
	
}
